<?php 
class CategoryAction extends ComAction{
	public function Index(){
		
		$db=M('cate');
		$cate=$db->order("sort")->select();
		
		import('class.Category',APP_PATH);
		//$cate=Category::UnlimteForLevel($cate,0,'&nbsp&nbsp--');
		$cate=Category::UnlimteForLevel($cate,0);
		//p($cate);die;
		$this->cate=$cate;
		$this->display();
	}
		
	
	//添加分类视图
	public function AddCate(){
		$pid=I('pid',0,'intval');
		$this->pid=$pid;
		$this->display();
		
	}
	//添加分类过程
	public function AddCateHandle(){
	 // p($_POST);die;
		if(M('cate')->add($_POST)){
	  	$this->success('添加成功',U(GROUP_NAME.'/Category/Index'));
	  	
	  }else{
	  	
	  	$this->success('添加失败',U(GROUP_NAME.'/Category/Index'));
	  }
		
	}
	
	public function SortCate(){
		//p($_POST);die;
		$db=M('cate');
		foreach ($_POST as $id => $sort){
		  $db->where(array('id'=>$id))->setField('sort', $sort);
		}
		$this->redirect(GROUP_NAME.'/Category/Index');
	}
}

?>